var t = getApp();

Page({
    data: {
        tag: "",
        sixCity: [],
        citys: [],
        city: "",
        JumpArray: [],
        position_switch: !1
    },
    onLoad: function(t) {
        "activityHome" == t.tag || "activitySearch" == t.tag || "activitySort" == t.tag || "search" == t.tag ? this.setData({
            tag: t.tag,
            isHome: !0
        }) : "storeConsume" == t.tag || "cake" == t.tag ? this.setData({
            tag: t.tag,
            id: t.id
        }) : t.tag && this.setData({
            tag: t.tag
        }), this._getSixCityList(), this._getCityList();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    _getSixCityList: function() {
        var a = "", i = this;
        a = "hotel" == this.data.tag ? "plugin.hotel.frontend.hotel.hotel.get-hot-citys" : "easyRefuel" == this.data.tag ? "plugin.easy-refuel.frontend.index.getHotCitys" : "activityHome" == this.data.tag || "activitySearch" == this.data.tag || "activitySort" == this.data.tag ? "plugin.activity-apply.api.index.getHotCitys" : "communityStore" == this.data.tag || "communityStoreDetails" == this.data.tag ? "plugin.store-community.frontend.community.getHotCitys" : "plugin.store-cashier.frontend.store.store.getHotCitys";
        var o = t.getNetAddresss(a);
        t._getNetWork({
            url: o,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    i.setData({
                        sixCity: a.data.citys
                    });
                    try {
                        "1" == a.data.position_switch && i.setData({
                            position_switch: !0
                        });
                    } catch (t) {
                        console.log(t);
                    }
                } else console.log(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _getCityList: function() {
        var a = "", i = this;
        a = "hotel" == this.data.tag ? "plugin.hotel.frontend.hotel.hotel.get-city-initials" : "easyRefuel" == this.data.tag ? "plugin.easy-refuel.frontend.index.getCitys" : "activityHome" == this.data.tag || "activitySearch" == this.data.tag || "activitySort" == this.data.tag ? "plugin.activity-apply.api.index.getCityInitials" : "communityStore" == this.data.tag || "communityStoreDetails" == this.data.tab ? "plugin.store-community.frontend.community.getCityInitials" : "plugin.store-cashier.frontend.store.store.getCityInitials";
        var o = t.getNetAddresss(a);
        t._getNetWork({
            url: o,
            success: function(t) {
                var a = t.data;
                if (1 == a.result) {
                    i.setData({
                        citys: a.data.initials
                    });
                    var o = a.data.initials.map(function(t) {
                        return String(t.title).substr(0, 1);
                    });
                    i.setData({
                        shortcutList: o
                    }), i.Jumpinit();
                } else console.log(a.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    goback: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    tosearch: function() {
        "storeConsume" != this.data.tag ? this.data.tag ? wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=" + this.data.tag
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc"
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=" + this.data.tag + "&id=" + this.data.id
        });
    },
    toGeolocation: function() {
        "storeConsume" != this.data.tag ? this.data.tag ? wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=" + this.data.tag
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc"
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oLocation_loc/o2oLocation_loc?tag=" + this.data.tag + "&id=" + this.data.id
        });
    },
    setCity: function(t) {
        var a = t.currentTarget.dataset.fulladdress;
        if (console.log(t), a) this.data.tag ? (this.setData({
            city: a
        }), "activityHome" == this.data.tag || "activitySearch" == this.data.tag || "activitySort" == this.data.tag ? wx.navigateTo({
            url: "/packageC/o2o/o2oCity/o2oCity?tag=" + this.data.tag + "&city=" + this.data.city
        }) : "storeConsume" == this.data.tag ? wx.navigateTo({
            url: "/packageC/o2o/o2oCity/o2oCity?tag=" + this.data.tag + "&city=" + this.data.city + "&id=" + this.data.id
        }) : "cake" == this.data.tag ? wx.navigateTo({
            url: "/packageF/sachertorte/sachertorteIndex/sachertorteIndex?city=" + this.data.city
        }) : wx.navigateTo({
            url: "/packageC/o2o/o2oCity/o2oCity?tag=" + this.data.tag + "&city=" + this.data.city
        })) : (this.setData({
            city: a
        }), wx.navigateTo({
            url: "/packageC/o2o/o2oCity/o2oCity?city=" + this.data.city
        })); else {
            this.setData({
                city: ""
            }), wx.setStorage({
                key: "address-point",
                data: {
                    point: {
                        lat: "0",
                        lng: "0"
                    },
                    city: ""
                }
            });
            if ("home" == this.data.tag) wx.reLaunch({
                url: "/packageG/index/index?addressData=" + JSON.stringify(this.data.mapmessageData)
            }); else if ("diy" == this.data.tag) {
                var i = wx.getStorageSync("diyurl");
                wx.reLaunch({
                    url: i
                });
            } else "cake" == this.data.tag ? wx.navigateTo({
                url: "/packageF/sachertorte/sachertorteIndex/sachertorteIndex"
            }) : wx.reLaunch({
                url: "/packageC/o2o/o2oHome/o2oHome?addressData=" + JSON.stringify({
                    title: "",
                    message: "",
                    latitude: "",
                    longitude: "",
                    city: ""
                })
            });
        }
    },
    Jump: function(t) {
        var a = t.currentTarget.dataset.index;
        wx.pageScrollTo({
            scrollTop: this.data.JumpArray[a],
            duration: 300
        });
    },
    Jumpinit: function() {
        var t = this, a = wx.createSelectorQuery();
        a.selectAll(".d_jump").boundingClientRect(), a.selectViewport().scrollOffset(), 
        a.exec(function(a) {
            var i;
            i = a[0].map(function(t) {
                return t.top;
            }), t.setData({
                JumpArray: i
            });
        });
    }
});